package team.first.school.controller;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 
 * @author aren
 *处理页面跳转的controller
 
 */
@Controller
public class PageController {
	/**
	 * 登录页面拦截
	 * @return
	 */
	@RequestMapping("/")
	public String showLogin(){
		return "login";
	}
	/**
	 * 处理登录请求拦截
	 * @param session
	 * @return
	 */
	@RequestMapping("/index")
	public String showIndex(HttpSession session){
		if(session.getAttribute("adminMessage") != null){
			return "index";
		} else {
			return "login";
		}
		
	}
	/**
	 * 通用页面跳转
	 * @param pageName
	 * @return
	 */
	@RequestMapping("/{pageName}")
	public String showPage(@PathVariable String pageName){
		return pageName;
	}
}
